package com.typhoon.extend.dao;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.typhoon.extend.entity.Account;

@Repository("accountDao")
public class AccountDao extends BaseDao {
	
	private static final String TABLE_ACCOUNT = "Account";
	
	@Resource
	private JdbcTemplate extendJdbc;

	public Account queryByCode(String accountCode) {
		StringBuilder sql = new StringBuilder();
		sql.append(select);
		sql.append(star);
		sql.append(from);
		sql.append(TABLE_ACCOUNT);
		sql.append(where);
		sql.append("	accountCode = ?	limit 1 ");
		List<Account> list = this.extendJdbc.query(sql.toString(), BeanPropertyRowMapper.newInstance(Account.class), accountCode);
		if(CollectionUtils.isEmpty(list)) {
			return null;
		}
		return list.get(0);
	}
	
	

}
